package com.lqs.sofp.servlet;

import com.alibaba.fastjson.JSON;
import com.lqs.sofp.entity.User;
import com.lqs.sofp.service.UserService;
import com.lqs.sofp.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
/**
 * @author lkh
 */
@WebServlet(name = "SelectUserInfoServlet", value = "/User/suis")
public class SelectUserInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("User");

        //将数据JSON化
        String jsonString = JSON.toJSONString(user);

        //响应数据
        response.getWriter().write(jsonString);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
